package Class;

import java.io.Serializable;
import java.util.ArrayList;

@SuppressWarnings("serial")
public class Commande implements Serializable {
	private ArrayList<ItemCommande> Items;
	private ArrayList<String> Notes;
	private Livraison livraion;
	private double sousTotal;
	private double taxeTPS;
	private double taxeTVQ;
	private double total;
	private int rabaisPourcent;
	private double rabais;
	private double sousTotalRabais;

	public Commande() {
		Items = new ArrayList<ItemCommande>();
		Notes = new ArrayList<String>();
		livraion = null;
	}

	public void add(ItemCommande item) {
		Items.add(item);
	}

	public ArrayList<ItemCommande> getItems() {
		return Items;
	}

	public void calculerFacture() {
		double sousTotal = 0.00;
		for (ItemCommande itemCommande : Items) {
			sousTotal += itemCommande.getItem().getPrix() * itemCommande.getQuantite();
		}
		this.sousTotal = sousTotal;
		if (rabaisPourcent > 0) {
			this.rabais = sousTotal * (Double.valueOf(String.valueOf(this.rabaisPourcent)) / 100);
			this.sousTotalRabais = sousTotal - this.rabais;
			sousTotal = this.sousTotalRabais;
		}
		double tps = sousTotal * 0.05;
		this.taxeTPS = tps;
		double tvq = (sousTotal + taxeTPS) * 0.095;
		this.taxeTVQ = tvq;
		double total = sousTotal + taxeTPS + taxeTVQ;
		this.total = total;

	}

	public Double getSousTotal() {
		return sousTotal;
	}

	public Double getTaxeTPS() {
		return taxeTPS;
	}

	public Double getTaxeTVQ() {
		return taxeTVQ;
	}

	public Double getTotal() {
		return total;
	}

	public void setLivraison(Livraison livraion) {
		this.livraion = livraion;
	}

	public void setRabaisPourcent(int rabais) {
		this.rabaisPourcent = rabais;
	}

	public int getRabaisPourcent() {
		return this.rabaisPourcent;
	}

	public Double getRabais() {
		return this.rabais;
	}

	public Double getSoutTotalRabais() {
		return this.sousTotalRabais;
	}

}
